cmake_minimum_required(VERSION 3.15.3)
project(JoystickCpp)

set(CMAKE_CXX_STANDARD 14)

INCLUDE_DIRECTORIES(src/main/resources/include)
#引入jni,$ENV{JAVA_HOME}是取系统环境变量的[JAVA_HOME]字段
INCLUDE_DIRECTORIES($ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/win32)
LINK_DIRECTORIES(src/main/resources/lib)

SET(JoystickModule
        src/main/cpp/joystick/JoystickManager.cpp
        src/main/cpp/joystick/JoystickTypeDef.cpp
        src/main/cpp/joystick/JoystickUtil.cpp
        src/main/cpp/common/CharsetConverter.cpp
        )
#DInput lib
SET(DInputLib
        dinput8.lib
        dxguid.lib
        )

#生成dll
#jna
ADD_LIBRARY(JoystickJna SHARED
        src/main/cpp/dllJna/JoystickJna.cpp
        ${JoystickModule}
        )
TARGET_LINK_LIBRARIES(JoystickJna ${DInputLib})

#ADD_LIBRARY(TestLib SHARED
#        src/main/cpp/dllJna/TestLib.cpp
#        src/main/cpp/joystick/JoystickTypeDef.cpp
#        )

#生成exe
ADD_EXECUTABLE(JoystickManagerTest
        src/main/cpp/test/JoystickManagerTest.cpp
        src/main/cpp/common/CommonUtil.cpp
        ${JoystickModule}
        )
TARGET_LINK_LIBRARIES(JoystickManagerTest ${DInputLib})

ADD_EXECUTABLE(JoystickJnaTest
        src/main/cpp/test/JoystickJnaTest.cpp
        src/main/cpp/common/CommonUtil.cpp
        ${JoystickModule}
        )
TARGET_LINK_LIBRARIES(JoystickJnaTest ${DInputLib})